package com.cmcc.groupcontacts.numbersearch.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.cmcc.groupcontacts.base.BaseAdapter;
import com.cmcc.groupcontacts.numbersearch.model.SearchNumber;
import com.yinhai.activity.R;

public class SearchNumberAdapter extends BaseAdapter<SearchNumber> {

	public final class ViewCache {
		public TextView content_textview;
	}

	private ViewCache viewCache = null;

	public SearchNumberAdapter(Context context) {
		super(R.layout.number_search_list_item, context, null);
	}

	public SearchNumberAdapter(Context context, List<SearchNumber> objects) {
		super(R.layout.number_search_list_item, context, objects);
	}

	@Override
	protected void setViewCache(View convertView, int position) {
		viewCache = new ViewCache();
		viewCache.content_textview = (TextView) convertView
				.findViewById(R.id.number_search_name);
		convertView.setTag(viewCache);
	}

	@Override
	protected void getViewCache(View convertView, int position) {
		viewCache = (ViewCache) convertView.getTag();
	}

	@Override
	protected void setValueByViewCache(View convertView, int position) {
		SearchNumber item = getItem(position);
		String content = item.name + " " + item.number;
		viewCache.content_textview.setText(content);
	}

}
